<?php
/**
 * 说明：卡品激活页面控制器
 * 
 */
class Activecard extends Controller {

	function Activecard()
	{
		parent::Controller();
		$this->load->library('myfunction');   //载入自定义函数库
		$this->load->model('card_model');   //载入访客接入判断模型
		@date_default_timezone_set('Etc/GMT+8');  //设置默认时区为GMT+8
	}

	function index() {
		$data['baseurl']=base_url();
		$data['head_info']="<link href=\"css/activecard.css\" type=\"text/css\" rel=\"stylesheet\"><script type=\"text/javascript\" src=\"js/ac_ajax.js\"></script><meta http-equiv=\"pragma\" content=\"no-cache\"> <meta http-equiv=\"cache-control\" content=\"no-cache\"> <meta http-equiv=\"expires\" content=\"0\">  ";//网页head区域信息
		$data['web_title']='好医生导医网——会员激活';//浏览器标题
		$this->load->view('topbar_view',$data);
		$this->load->view('activecard_view',$data);
	}

	//ajax传递过来的卡号查询
	function ck_cardno() {
		parse_str($_SERVER['QUERY_STRING'], $_GET);//启用GET方式
		$cardno=strtoupper($this->input->get('cardno'));//转换成大写
		$ck=$this->card_model->ck_cardno($cardno);
		echo $ck;//输出查询结果供ajax判断
	}

	function ac_do() {
		$ac['cardno']=strtoupper($this->input->post('cardno'));//转换成大写
		$ac['areacode']='HA'.substr($ac['cardno'],2,2);
		$ck=$this->card_model->ck_cardno($ac['cardno']);//再次进行重复值判断
		if($ck==0) {
			$error['detail']="您的卡号已经激活过，请不要重复激活！";
			$error['min']=3;
			$error['url']=base_url()."activecard";
			$this->load->view('manage/errormsg_view',$error);
		}
		$ac['name']=$this->input->post('name');
		$ac['sex']=$this->input->post('sex');
		$ac['birth']=$this->input->post('birth');
		$ac['cellphone']=$this->input->post('cellphone');
		$ac['address']=$this->input->post('address');
		$ac['tel']=$this->input->post('tel');
		$ac['member']=$this->input->post('member');
		$ac['actime']= now();
		$ac['acip']=$this->input->ip_address();//IP
		if($this->card_model->ac_do($ac)==0) {
			$msg['detail']="恭喜您".$ac['name']."，您的激活信息已提交成功！";
			$msg['min']=3;
			$msg['url']=base_url();
            $this->load->view('manage/message_view',$msg);
		}else{
			$error['detail']="非常抱歉，由于系统原因未能成功激活，请选择其他激活方式！";
			$error['min']=3;
			$error['url']=base_url();
			$this->load->view('manage/errormsg_view',$error);
		}

	}

}
?>